package cn.tedu.mall.test.order.inter;

import java.util.HashMap;
import java.util.Map;

public class DinfanguoContext implements DianfanguoInterface{
    //准备好当前所有实例对象和条件的注册关系
    private static Map<String,DianfanguoInterface> register=new HashMap<>();
    static {
        //初始化的时候,将所有条件对应的实现类的关系,在这里定义好
        register.put("炒菜",new DianfanguoChaocaiImpl());
        register.put("煮饭",new DianfanguoZhufanImpl());
        register.put("煮粥",new DianfanguoZhuzhouImpl());
    }
    @Override
    public void run() {

    }
    //对外调用的时候,run重载方法
    public void run(String condition){
        DianfanguoInterface dianfanguoInterface = register.get(condition);
        if (dianfanguoInterface!=null){
            dianfanguoInterface.run();
        }else{
            System.out.println("没有这个条件对应的实现类");
        }
    }
}
